import 'package:bruno/bruno.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:sph_shipper/Order/WaybillDetails/CostNegotiation.dart';
import 'package:sph_shipper/Order/WaybillDetails/DirectComplaints.dart';
import 'package:sph_shipper/Order/WaybillDetails/FrequentlyAQ.dart';
import 'package:sph_shipper/Order/WaybillDetails/SingleComplaint.dart';

import '../../AppConfig/Config.dart';
import 'ComplaintOfBeingLate.dart';
import 'DocumentDisputes.dart';
import 'DriverMarkup.dart';

class InitiateComplaint extends StatefulWidget {
  const InitiateComplaint({super.key, required this.dataMap});
  final Map dataMap;
  @override
  State<InitiateComplaint> createState() => _InitiateComplaintState();
}

class _InitiateComplaintState extends State<InitiateComplaint> {
  List QAList=["货损情况怎么办？","禁区被罚款了，货主不愿意负责怎么办？","司机临时要加钱怎么处理？","司机一只拖着不寄回单","我被押车了，怎么办？","司机迟到爽约怎么处理？",
  "投诉单显示对方已拒绝？","被投诉在哪里看？","投诉显示待货主确认怎么处理？","投诉有效期是多久？","各项纠纷补偿费用标准是什么？","货主不赔偿放空怎么办？"];
  @override
  void _copyToClipboard(String copyNumber) {
    Clipboard.setData(ClipboardData(text: copyNumber));
    BrnToast.show('复制成功', context);

  }
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    return Scaffold(
      backgroundColor: MyColors.backgreyColor,
        appBar: AppBar(
        title:Text( "投诉服务",style: TextStyle(fontWeight: FontWeight.w300,fontSize: 16.sp),),
        backgroundColor: Colors.white,
        centerTitle: true,
        ),
      body: ListView(
        children: [
          // Container(
          //   margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 8.h),
          //   padding: EdgeInsets.only(top: 13.h,bottom: 13.h,right: 4.w),
          //   decoration: BoxDecoration(
          //       color: Colors.white,
          //       borderRadius: BorderRadius.all(Radius.circular(10))),
          //   child: Row(
          //     mainAxisAlignment: MainAxisAlignment.spaceBetween,
          //     crossAxisAlignment: CrossAxisAlignment.center,
          //     children: [
          //       Row(
          //         children: [
          //           Container(width: 4.w,height: 16.h,color: MyColors.themeColor,),
          //           SizedBox(width: 14.w,),
          //           Text("请选择协商类型",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
          //         ],
          //       ),
          //       GestureDetector(
          //         child: Row(
          //           children: [
          //             Text("去协商",style: TextStyle(color: MyColors.themeColor),),
          //             Icon(Icons.arrow_forward_ios,color: MyColors.themeColor,size: 20,),
          //           ],
          //         ),
          //         onTap: (){
          //           Navigator.push(context,
          //               MaterialPageRoute(builder: (context) {
          //                 return const CostNegotiation(
          //                 );
          //               }));
          //         },
          //       ),
          //     ],
          //   ),
          // ),
          // Container(
          //   margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 8.h),
          //   padding: EdgeInsets.only(top: 10.h,bottom: 10.h,right: 11.w,left: 11.w),
          //   decoration: BoxDecoration(
          //       color: Colors.white,
          //       borderRadius: BorderRadius.all(Radius.circular(10))),
          //   child: Container(
          //     padding: EdgeInsets.only(left: 9.w,right: 12.w,top: 10.h,bottom: 10.h),
          //
          //     decoration: BoxDecoration(
          //       color: Color.fromRGBO(255, 191, 107, 0.1),
          //       borderRadius: BorderRadius.all(Radius.circular(10)),
          //       border: Border.all(color: Color.fromRGBO(240, 133, 44, 1), width: 1), // 设置边框颜色和宽度
          //     ),
          //     child: Row(
          //       mainAxisAlignment: MainAxisAlignment.spaceBetween,
          //       children: [
          //         Row(
          //           children: [
          //             Image.asset("lib/Images/OrderList/投诉服务协商icon.png",width: 34.w,height: 34.h,),
          //             SizedBox(width: 5.w,),
          //             Column(
          //               crossAxisAlignment: CrossAxisAlignment.start,
          //               children: [
          //                 Text("先行协商更高效",style: TextStyle(color: Colors.black),),
          //                 Text("司机迟到爽约、加价费退还",style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),),
          //               ],
          //             ),
          //           ],
          //         ),
          //         Icon(Icons.arrow_forward_ios,size: 20,color: MyColors.hintColor,),
          //       ],
          //     ),
          //   ),
          // ),

      Container(
      margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 8.h),
      padding: EdgeInsets.only(top: 10.h,bottom: 10.h,right: 10.w,left: 10.w),
      decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.all(Radius.circular(10))),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                Text("运单编号：28135181324748264",style: TextStyle(color: MyColors.authTipColor,fontSize: 14.sp),),
                GestureDetector(
                  child: Icon(Icons.filter_none,color: MyColors.authTipColor,size: 20,),
                  onTap: (){
                    _copyToClipboard("28135181324748264");
                  },
                ),
              ],
            ),
            Container(
              width: screenSize.width-40.w,
              margin: EdgeInsets.only(top: 8.h),
              padding: EdgeInsets.only(top: 10.h,bottom: 10.h,right: 10.w,left: 10.w),
              decoration: BoxDecoration(
                  color: Color.fromRGBO(251, 236, 228, 0.5),
                  borderRadius: BorderRadius.all(Radius.circular(10))),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    children: [
                      Text("苏州市吴中区",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                      Icon(Icons.arrow_right_alt,color: Colors.black,size: 20,),
                      Text("苏州市吴中区",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                    ],
                  ),
                  SizedBox(height: 2.h,),
                  Text("对方姓名:小易",style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),),
                  SizedBox(height: 2.h,),
                  Text("手机号:15888888888",style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),),
                  SizedBox(height:2.h,),
                  Text("交易时间:2024-03-06 10:09:27",style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),),
                ],
              ),
            ),
          ],
        ),
      ),
          Container(
            margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 8.h),

            decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.all(Radius.circular(10))),
            child: BrnNoticeBar(
              content: '先行协商更高效，如协商失败，可申请人工介入',
              showRightIcon: false,
              textColor: MyColors.themeColor,
              leftWidget: Icon(Icons.volume_up,color: MyColors.themeColor,),
              backgroundColor: Color.fromRGBO(251, 236, 228,1),
              noticeStyle: NoticeStyles.runningWithArrow,

            ),
          ),

          Container(
            margin: EdgeInsets.only(left: 10.w,right: 10.w),
            padding: EdgeInsets.only(bottom: 21.h,right: 4.w,top: 8.h),
            decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.all(Radius.circular(10))),
            child: Column(
              children: [

                Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Row(
                      children: [
                        Container(width: 4.w,height: 16.h,color: MyColors.themeColor,),
                        SizedBox(width:14.w ,),
                        Text("请选择投诉问题类型",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                      ],
                    ),
                    GestureDetector(
                      child: Row(
                        children: [
                          Text("直接投诉",style: TextStyle(color: MyColors.themeColor),),
                          Icon(Icons.arrow_forward_ios,color: MyColors.themeColor,size: 20,),
                        ],
                      ),
                      onTap: (){
                        Navigator.push(context,
                            MaterialPageRoute(builder: (context) {
                              return const DirectComplaints(
                              );
                            }));
                      },
                    ),
                  ],
                ),
                Divider(height: 16.h,color: MyColors.backgreyColor,),
                GestureDetector(
                  child:  Row(
                    children: [
                      SizedBox(width: 15.w,),
                      Image.asset("lib/Images/OrderList/回单纠纷icon.png",width: 35.w,height: 35.h,),
                      SizedBox(width:10.w ,),
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text("回单纠纷",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                          Text("司机不寄回单/丢失",style: TextStyle(color: MyColors.textColor),),
                        ],
                      ),
                    ],
                  ),
                  onTap: (){
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) {
                          return  DocumentDisputes(
                          );
                        }));
                  },
                ),
                SizedBox(height: 18.h,),
                GestureDetector(
                  child:  Row(
                    children: [
                      SizedBox(width: 15.w,),
                      Image.asset("lib/Images/OrderList/司机迟到爽约icon.png",width: 35.w,height: 35.h,),
                      SizedBox(width:10.w ,),
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text("司机迟到/爽约",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                          Text("司机迟到或联系不上",style: TextStyle(color: MyColors.textColor),),
                        ],
                      ),
                    ],
                  ),
                  onTap: (){
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) {
                          return  ComplaintOfBeingLate(
                          );
                        }));
                  },
                ),
                SizedBox(height: 18.h,),
                GestureDetector(
                  child:  Row(
                    children: [
                      SizedBox(width: 10.w,),
                      Image.asset("lib/Images/OrderList/司机加价多收钱icon.png",width:50.w,height: 50.h,),
                      // SizedBox(width:10.w ,),
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text("司机加价/多收钱",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                          Text("司机恶意加价/多收运费",style: TextStyle(color: MyColors.textColor),),
                        ],
                      ),
                    ],
                  ),
                  onTap: (){
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) {
                          return  DriverMarkup(
                          );
                        }));
                  },
                ),
                SizedBox(height: 18.h,),
                GestureDetector(
                  child:  Row(
                    children: [
                      SizedBox(width: 15.w,),
                      Image.asset("lib/Images/OrderList/货物损失其他损失icon.png",width: 40.w,height: 40.h,),
                      SizedBox(width:10.w ,),
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text("货损/拉跑货",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                          Text("货损/拉跑货",style: TextStyle(color: MyColors.textColor),),
                        ],
                      ),
                    ],
                  ),
                  onTap: (){
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) {
                          return  SingleComplaint(
                          );
                        }));
                  },
                ),
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 8.h),
            padding: EdgeInsets.only(top: 13.h,bottom: 16.h,right: 4.w,),
            decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.all(Radius.circular(10))),
            child: Column(
              children: [
                Row(
                  children: [
                    Container(width: 4.w,height: 16.h,color: MyColors.themeColor,),
                    SizedBox(width:14.w ,),
                    Text("投诉常见问题",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                  ],
                ),
                Container(
                  height:37.h*QAList.length,
                  child:  ListView.builder(
                padding: EdgeInsets.zero, // 设置padding为零
                      itemCount: QAList.length,
                      itemBuilder: (BuildContext context,
                          int index) {
                  return Column(
                    children: [
                      Divider(height: 16.h,color: MyColors.backgreyColor,),
                      GestureDetector(
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Row(
                              children: [
                                SizedBox(width: 14.w,),
                                Icon(Icons.help_outline,color: MyColors.authTipColor,),
                                SizedBox(width: 10.w,),
                                Container(
                                  width:screenSize.width-100.w,
                                  child:  Text(QAList[index],style: TextStyle(color: Colors.black,fontSize: 16.sp),maxLines: 1, // 设置最大行数为1
                                    overflow: TextOverflow.ellipsis, ),
                                ),

                              ],
                            ),
                            Icon(Icons.arrow_forward_ios,size: 20,color: MyColors.authTipColor,),

                          ],
                        ),
                        onTap: (){
                          Navigator.push(context,
                              MaterialPageRoute(builder: (context) {
                                return const FrequentlyAQ(
                                );
                              }));
                        },
                      ),

                    ],
                  );
                      }),
                )
              ],
            ),
          ),
        ],
      ),
    );
  }
}
